import { atom } from 'jotai';
import { atomWithStorage } from 'jotai/utils';
import { createJSONStorageWithCookies } from 'src/utils/jotai';

export type AppTheme = 'light' | 'dark';

export interface User {
  id: string;
  name: string;
  email: string;
  avatar?: string;
  phone?: string;
  bio?: string;
  role: string;
  isActive: boolean;
  isVerified: boolean;
}

export interface StorageSystemOption {
  label: string;
  value: string;
  isPublic: boolean;
  disabled?: boolean;
  description?: string | null;
}

/**
 * app 主题
 */
export const appThemeAtom = atomWithStorage<AppTheme>(
  'appTheme',
  'light',
  createJSONStorageWithCookies(),
  {
    getOnInit: true,
  }
);

/**
 * 用户信息
 */
export const userAtom = atom<User>();

/**
 * 用户存储系统实例列表
 */
export const storageSystemOptionsAtom = atom<StorageSystemOption[]>([]);
